# pid = fork  do
#     count = 0 
#     while count < 20
#       p count
#       count  = count + 1
#       sleep 1
#     end
# end

# Process.detach(pid)

# Process.wait


# fork && Process.wait
Signal.trap("CLD")  { puts "Child died" }

s = Time.now
pid = fork  do
  Signal.trap(0, proc { puts "Terminating: #{$$}" })

    count = 0 
    while count < 5
      p count,"in chaild"
      count  = count + 1
      sleep 1
    end
end

    count = 0 
    while count < 6
      p count,"in master"
      count  = count + 1
      sleep 1
    end
e = Time.now 
p e-s
Process.detach(pid)
Process.wait